﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace WoWConnecter.Entities
{
    /// <summary>
    /// A player controlled character
    /// </summary>
    public class Character : Unit
    {
        public ClassId Class { get; protected set; }
        public byte Skin { get; protected set; }
        public byte Face { get; protected set; }
        public byte HairStyle { get; protected set; }
        public byte HairColour { get; protected set; }
        public byte FacialHair { get; protected set; }
        public byte Outfit { get; protected set; }
        public int Zone { get; protected set; }
        public int Region { get; protected set; }

        public bool Thinking { get; set; }

        public uint GuildId { get; protected set; }

        public CharEnumFlags Flags { get; protected set; }

        public int CustomizationFlags { get; protected set; }

        public ChatLanguage DefaultLanguage
        {
            get
            {
                switch (Race)
                {
                    case RaceId.Human:
                    case RaceId.NightElf:
                    case RaceId.Draenei:
                    case RaceId.Dwarf:
                    case RaceId.Gnome:
                        return ChatLanguage.Common;
                    case RaceId.Orc:
                    case RaceId.Tauren:
                    case RaceId.Troll:
                    case RaceId.BloodElf:
                    case RaceId.Undead:
                        return ChatLanguage.Orcish;
                    default:
                        return ChatLanguage.Universal;
                }
            }
        }

        public Character(string name, RaceId race, ClassId chrClass, byte skin, byte face, byte hairStyle, byte hairColour)
        {
            Name = name;
            Race = race;
            Class = chrClass;
            Skin = skin;
            Face = face;
            HairStyle = hairStyle;
            HairColour = hairColour;
        }

        /// <summary>
        /// Used when we get a character via Name Request
        /// </summary>
        /// <param name="packet"></param>
        public Character(RealmPacketIn packet)
        {
            Id = EntityId.ReadPacked(packet);
            packet.ReadByte();

            Name = packet.ReadCString();
            packet.ReadByte();

            Race = (RaceId)packet.ReadByte();
            Gender = (GenderType)packet.ReadByte();
            Class = (ClassId)packet.ReadByte();

            packet.ReadByte();
        }

        public Character()
        {
        }

        public void Whisper(string message, params object[] args)
        {

        }
    }
}
